{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="js"}
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/plugins/validate/messages_zh.min.js"></script>
<script type="text/javascript">

    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
    $().ready(function() {
        $('select[name=user_type]').change();
        var e = "<i class='fa fa-times-circle'></i> ";
        $("#commentForm").validate({
            rules: {
                name: "required",
                tel: 'required',
                referee_code:'required'
            },
            messages: {
                name: e + "请输入姓名",
                tel: e + "请输入手机号",
                referee_code: e + "请输入推荐人编号",

            },
            submitHandler: function(form){
                if ($(form).hasClass('ed')) {
                    return false;
                }

                $(form).addClass('ed');
                $.post('', $(form).serialize(), function(data){
                    layer.msg(data.info);
                    if (data.status == 'y') {
                        setTimeout(function(){window.location.href = '{:url("index")}';},1500);
                    } else {
                        $(form).removeClass('ed');
                    }
                }, 'json');
            },
            invalidHandler: function(form, validator) {  //不通过回调
                return false;
            }
        })
    });

    function checkType(self) {
        var type = $(self).val();
        if (type == 3) {
            $('.js-puser').show();
            $('.js-shop').show();
        } else if (type == 2) {
            $('.js-puser').hide();
            $('.js-shop').show();
        } else {
            $('.js-puser').hide();
            $('.js-shop').hide();
        }
    }
</script>
{/block}
{block name='body'}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{empty name='data'}添加{else/}修改{/empty}用户</h5>
                        <a href="{:url('index')}" class="btn btn-sm btn-primary pull-right m-t-n-xs">返回</a>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal" id="commentForm" action="" onsubmit="return false;" >
                            <input type="hidden" value="{$data.id|default=''}" name="id" />

							<div class="form-group">
                                <label class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-8">
                                    <input type="text" maxlength="20" name="name" value="{$data.name|default=''}" class="input-sm form-control">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">手机号</label>
                                <div class="col-sm-8">
                                    <input type="number" maxlength="11" name="tel" value="{$data.tel|default=''}" class="input-sm form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">推荐人编号</label>
                                <div class="col-sm-8">
                                    <input type="text" {if $data}readonly {else} lay-verify="required"{/if} name="referee_code" value="{$data.referee_code|default=''}" class="input-sm form-control">
                                </div>
                            </div>
                            {if $info}
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">等级</label>
                                <div class="col-sm-8">
                                    <select class="input-sm form-control" name="user_type" >
                                        {foreach name="level" item="li"}
                                        <option value="{$li.id}" {if $data.user_type == $vo.id}selected{/if}>{$li.title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            {/if}
                            <!-- <div class="form-group js-puser" style="display: none;">
                                <label class="col-sm-2 control-label">上级店长</label>
                                <div class="col-sm-8">
                                    <select class="input-sm form-control" name="pid">
                                        <option value="0">请选择上级店长</option>
                                        {foreach name="puser" item="li"}
                                        <option value="{$key}" {if condition="isset($data['pid']) && $data['pid'] eq $key"}selected{/if}>{$li.name} | {$li.tel}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>

                            <div class="form-group js-shop" style="display: none;">
                                <label class="col-sm-2 control-label">所属店铺</label>
                                <div class="col-sm-8">
                                    <select class="input-sm form-control" name="shop_id">
                                        <option value="0">请选择所属店铺</option>
                                        {foreach name="shop_list" item="li"}
                                        <option value="{$li.id}" {if condition="isset($data['shop_id']) && $data['shop_id'] eq $li['id']"}selected{/if}>{$li.title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div> -->
                            <!-- <div class="form-group">
                                <label class="col-sm-2 control-label">USDT地址</label>
                                <div class="col-sm-8">
                                    <input type="text"  name="usdt_addr" value="{$data.usdt_addr|default=''}" class="input-sm form-control">
                                </div>
                            </div> -->
                          
                            <!-- <div class="form-group">
                                <label class="col-sm-2 control-label">余额</label>
                                <div class="col-sm-8">
                                    <input type="number" min="0" max="9999999.99" step="0.01" name="balance" value="{$data.balance|default=''}" class="input-sm form-control">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">钱包</label>
                                <div class="col-sm-8">
                                    <input type="number" min="0" max="9999999.99" step="0.01" name="jbalance" value="{$data.jbalance|default=''}" class="input-sm form-control">
                                </div>
                            </div> -->
                            <div class="form-group" style="margin-left: 20px;color: red;">
                            初始登录密码：111111，支付密码：222222
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
{/block}
